#!/bin/bash

a=`ls /lianxi/ |egrep back`
[ -z "$a" ]&&echo "目录已存在不需要创建"||mkdir /lianxi/back &>/dev/null
cd /lianxi/back/
time=`date +%Y_%m_%d_%T`
backup=${time}log.tar.gz
echo "$backup"
tar -zcvf /lianxi/back/$backup /var/log/xferlog &>/dev/null
echo "备份成功"

find /lianxi/back/ -name '*.gz' -mtime 1 -exec rm -rf '{}' ';'
echo "delete success"
